﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace TwitterTrendsSilverlightWebPart.Classes
{
    public class TweetItem
    {
        public string Tweet { get; set; }

        private string profileImageUrl;
        public string ProfileImageUrl
        {
            get
            {
                // if the avatar image is a gif, replace it with Twitter's default avatar.
                if (profileImageUrl.Contains(".gif"))
                    return "http://a0.twimg.com/a/1295051201/images/default_profile_0_reasonably_small.png";
                else
                    return profileImageUrl;
            }
            set { profileImageUrl = value; }
        }

        public DateTime Published { get; set; }

        private string author;
        public string Author
        {
            get { return author; }
            set { author = value.Remove(value.IndexOf("(")); }
        }
        public string AuthorURL { get; set; }
        public string Source { get; set; }

        public string TimePassed
        {
            get
            {
                int ts = Convert.ToInt32((DateTime.Now - Published).TotalMinutes);
                if (ts <= 60)
                    return ts + " MINUTES AGO";
                else
                    return (ts / 60) + " HOURS AGO";
            }
        }
    }
}
